import { JointContent, MessageInstance } from "antd/es/message/interface";
import { create } from "zustand";
import { combine } from "zustand/middleware";

interface MsgType {
  type: keyof Omit<MessageInstance, "open" | "destroy">;
  content: JointContent;
}

export const useSystemStore = create(
  combine(
    {
      search: "",
      _message: null as null | MsgType,
    },
    (set) => ({
      message: (type: MsgType["type"], content: MsgType["content"]) => {
        set({ _message: { type, content } });
      },
      setSearch: (search: string) => {
        set({ search });
      },
    })
  )
);
